﻿using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;

public class EventDispatcher : MonoBehaviour
{
    public delegate void ui_event_btn(GameObject btn, UserOperate.btnState btnState);
    public delegate void ui_event_camera();
    public delegate void ui_event_drop(GameObject dragObj, UserOperate.dragState dragState, PointerEventData eventData);
    public delegate void ui_event_key();
    public delegate void ui_event_mouse();

    public static event ui_event_btn btnEvent;
    public static void onBtnEvent(GameObject btn, UserOperate.btnState btnState)
    {
        btnEvent(btn, btnState);
    }

    public static event ui_event_drop dropEvent;
    public static void onDropEvent(GameObject dragObj, UserOperate.dragState dragState, PointerEventData eventData)
    {
        dropEvent(dragObj, dragState, eventData);
    }

    void Start()
    {
        //进行初始化，避免空监听时报错
        btnEvent += (o, s) => { };
        dropEvent += (o, s, e) => { };
    }

    public static void CleanListener(int iType=0)
    {
        switch (iType)
        {
            case 0:
                btnEvent -= btnEvent;
                dropEvent -= dropEvent;
                break;
            case 1:
                btnEvent -= btnEvent;
                break;
            case 2:
                dropEvent -= dropEvent;        
                break;
        }
        
    }

}
